package controller.api;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.kit.Ret;

import common.inter.ServicerStationInter;
import common.inter.StaffStationInter;
import model.ComsumablesRepalce;
import service.ComsumablesRepalceService;

public class ApiComsumablesRepalceController extends BaseApiController {
	@Inject ComsumablesRepalceService comsumablesRepalceService ;

	@Before(ServicerStationInter.class)
	public void list() {
	    Kv kv = getParamKv() ;
	    kv.set("tcr.stationId" , getStation().getId());
	    Integer pageNumber = getParaToInt("pageNumber", 1);
	    Integer pageSize = getParaToInt("pageSize", 10);
	    set("page", comsumablesRepalceService.getApiPage( kv , pageNumber, pageSize));
	    renderJson();
	}

	@Before(StaffStationInter.class)
	public void save() {
		ComsumablesRepalce comsumablesRepalce = getModel(ComsumablesRepalce.class , "x");
        Ret ret = comsumablesRepalceService.save(comsumablesRepalce , getStaff() , getStation() );
        renderJson(ret);
	}
}
